package com.clickpaas.materialsprocurement.service.Impl;

import com.bizcloud.ipaas.t0ba0ba6afb694026b6b4e4e048af2b43.d20210202135416.model.InquiryLineDTOResponse;
import com.clickpaas.materialsprocurement.dao.InquiryOrderLineDao;
import com.clickpaas.materialsprocurement.entity.InquiryOrderLineEntity;
import com.clickpaas.materialsprocurement.service.InquiryOrderLineService;
import com.clickpaas.materialsprocurement.utils.DataInfoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class InquiryOrderLineServiceImpl implements InquiryOrderLineService {
    @Resource
    private InquiryOrderLineDao inquiryOrderLineDao;

    /**
     * 获取询价单行数据
     *
     * @param inquiryOrderLineEntity
     * @return
     */
    @Override
    public List<InquiryLineDTOResponse> getInquiryOrderLineInfo(InquiryOrderLineEntity inquiryOrderLineEntity) {
        List<InquiryLineDTOResponse> reList;
        try {
            /**
             * 入参为空,不查询
             */
            if (null == inquiryOrderLineEntity || DataInfoUtil.isAllFieldNull(inquiryOrderLineEntity)){
                return null;
            }else {
                reList = inquiryOrderLineDao.getInquiryOrderByCondtion(inquiryOrderLineEntity);
            }
        } catch (Exception e) {
            log.info("入参对象异常,请检查：【{}】,报错信息：【{}】",inquiryOrderLineEntity,e);
            return null;
        }
        if (null != reList && reList.size()>0){
            return reList;
        }
        return null;
    }

    /**
     * 询价单行数据转换为bean
     *
     * @param list
     * @return
     */
    @Override
    public List<InquiryOrderLineEntity> InquiryOrderLineDataConver(List<InquiryLineDTOResponse> list) {
        return DataInfoUtil.castListCopy(list,InquiryLineDTOResponse.class,InquiryOrderLineEntity.class);
    }
}
